package com.canyou.system.model;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.Version;
import com.canyou.base.BaseModel;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
 * <p>
 * 操作日志表
 * </p>
 *
 * @author canyou
 * @since 2019-06-25
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("sys_oper_log")
@ApiModel(value="OperLog对象", description="操作日志表")
public class OperLog extends BaseModel {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "操作的业务模块")
    @TableField("module")
    private String module;

    @ApiModelProperty(value = "请求url")
    @TableField("request_url")
    private String requestUrl;

    @ApiModelProperty(value = "请求类型（GET POST PUT DELETE)")
    @TableField("request_type")
    private String requestType;

    @ApiModelProperty(value = "方法参数")
    @TableField("request_param")
    private String requestParam;

    @ApiModelProperty(value = "操作状态（0正常 1异常）")
    @TableField("response_code")
    private Integer responseCode;

    @ApiModelProperty(value = "返回值")
    @TableField("response_data")
    private String responseData;

    @ApiModelProperty(value = "错误消息")
    @TableField("response_msg")
    private String responseMsg;

    @ApiModelProperty(value = "请求来源id")
    @TableField("client_id")
    private String clientId;

    @ApiModelProperty(value = "操作用户")
    @TableField("username")
    private String username;

    @ApiModelProperty(value = "操作内容")
    @TableField("operation")
    private String operation;

    @ApiModelProperty(value = "操作者IP")
    @TableField("ip_addr")
    private String ipAddr;

    @ApiModelProperty(value = "操作地点")
    @TableField("location")
    private String location;

    @ApiModelProperty(value = "耗时")
    @TableField("spend_time")
    private Long spendTime;

    @ApiModelProperty(value = "开始时间")
    @TableField(exist = false)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;

    @ApiModelProperty(value = "结束时间")
    @TableField(exist = false)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;

}
